package xin.fsqr520.project.domain.po;

import lombok.Getter;

/**
 * WebSocket消息类型枚举
 */
@Getter
public enum WsMessageType {
    CONNECT_SUCCESS("connect_success"),
    CONNECT_ERROR("connect_error"),
    SEND_SUCCESS("send_success"),
    SEND_ERROR("send_error"),
    PRIVATE("private");

    private final String type;

    WsMessageType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return type;
    }

    public static WsMessageType from(String s) {
        for (WsMessageType type : values()) {
            if (type.type.equalsIgnoreCase(s)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid message type: " + s);
    }
}
